<?php
$this->title = "文章栏目管理";
//echo "10".3;
//var_dump($tree[2]['depth']*3);
?>
<div class="main">
	<div class="header">文章栏目管理</div>
	<div class="oper">
		<a href="<?=ROOT_URL?>article/catcreate" class='btn btn-primary'>增加顶级栏目</a>
	</div>
	<div>
		<ul id="tree">
		<?php
		tree($tree);
		function tree($tree){
			foreach ($tree as $value) {
				echo "<li>
						<a href=\"javascript:delCategory('".$value['id']."','".$value['name']."');\" class='delSub'>删除</a>
						<a href='".ROOT_URL."article/catupdate&id=".$value['id']."'>更改</a>
						<a href='".ROOT_URL."article/catcreate&id=".$value['id']."'>增加子类</a>";
				echo "<span style='margin-left:".(string)($value['depth']*30)."px'>".$value['name']."</span><input type='hidden' class='catid' value='".$value['id']."'></li>";

				if ($value['children'] != null) {
					tree($value['children']);
				}
			}
		}
		?>
		</ul>
	</div>
</div>
<script type="text/javascript">
function delCategory(id,name){
	if(confirm("确定要删除栏目 "+name+ " 及其子类吗")){
		$.post("<?=ROOT_URL?>article/deletecat",{id:id},function(){
			window.location.reload();
		})
	}
		
}
</script>